package com.webchat.domain.dto.payment;


import com.webchat.domain.enums.payment.PaymentResultCodeEnum;
import lombok.Data;

@Data
public class PaymentResultDTO {

    /**
     * 支付结果
     *
     * @see com.webchat.domain.enums.payment.PaymentResultCodeEnum
     */
    private Integer code;

    private String msg;

    private CallBackRequestBodyDTO data;

    public PaymentResultDTO() {

    }

    public static PaymentResultDTO error(PaymentResultCodeEnum codeEnum) {

        return error(codeEnum, null);
    }

    public static PaymentResultDTO error(PaymentResultCodeEnum codeEnum,
                                         CallBackRequestBodyDTO data) {
        PaymentResultDTO result = new PaymentResultDTO();
        result.setCode(codeEnum.getCode());
        result.setMsg(codeEnum.getDesc());
        result.setData(data);
        return result;
    }

    public static PaymentResultDTO ok() {
        return ok(null);
    }

    public static PaymentResultDTO ok(CallBackRequestBodyDTO data) {
        PaymentResultDTO result = new PaymentResultDTO();
        result.setCode(PaymentResultCodeEnum.OK.getCode());
        result.setMsg(PaymentResultCodeEnum.OK.getDesc());
        result.setData(data);
        return result;
    }
}
